package com.briup.day22;

import java.io.File;
import java.io.IOException;

/**
 * 创建和删除操作
 */
public class Test_File {
    public static void main(String[] args) throws IOException {
        File file =new File("D:/briup/dir");
        System.out.println(file.exists());
        //创建目录
        boolean flag = file.mkdir();
        System.out.println(flag);
        System.out.println(file.exists()+"----------------------------------------");
        File file2 =new File("D:/a/b");
        System.out.println(file2.exists());
        //级联创建
        flag = file2.mkdirs();
        System.out.println(flag);
        System.out.println("----------------------------------------");
        File f2=new File(file,"a.txt");
        flag = f2.createNewFile();//可能有异常
        System.out.println(flag);
        //删除非空目录
        flag = file.delete();
        System.out.println(flag);//false
        System.out.println("--------------------------------");
        flag = f2.delete();
        System.out.println(flag);
        System.out.println("--------------------------------");

    }
}
